package org.jeecg.modules.charge.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.charge.entity.ChargeInvoiceInhouse;
import org.jeecg.modules.charge.entity.ChargeInvoiceRecords;
import org.jeecg.modules.charge.mapper.ChargeInvoiceInhouseMapper;
import org.jeecg.modules.charge.mapper.ChargeInvoiceRecordsMapper;
import org.jeecg.modules.charge.service.IChargeInvoiceRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 领用记录
 * @Author: jeecg-boot
 * @Date:   2019-08-14
 * @Version: V1.0
 */
@Service
public class ChargeInvoiceRecordsServiceImpl extends ServiceImpl<ChargeInvoiceRecordsMapper, ChargeInvoiceRecords> implements IChargeInvoiceRecordsService {

    @Autowired
    private ChargeInvoiceRecordsMapper chargeInvoiceRecordsMapper;
    @Autowired
    private ChargeInvoiceInhouseMapper ChargeInvoiceInhouseMapper;


    @Override
    public Integer selectMaxSer() {
        return chargeInvoiceRecordsMapper.selectMaxSer();
    }

    @Override
    public Boolean saveBar(ChargeInvoiceRecords chargeInvoiceRecords1) {
        chargeInvoiceRecordsMapper.insert(chargeInvoiceRecords1);
        return true;
    }

    @Override
    public List<String> getDepartIds(String id) {
        return chargeInvoiceRecordsMapper.getDepartIds(id);
    }


    public Page<ChargeInvoiceInhouse> getChargeInvoiceReport(Page<ChargeInvoiceInhouse> page,ChargeInvoiceInhouse inhouse){
        List<String> departIds = chargeInvoiceRecordsMapper.getDepartIds(inhouse.getId());//获取机构Id
        List<ChargeInvoiceInhouse> houseList = null;
        if(null != departIds && departIds.size()> 0){
            houseList =  ChargeInvoiceInhouseMapper.getIhouseByDepartIds(departIds);
        }
        return page.setRecords(houseList);
    }

    public List<ChargeInvoiceInhouse> getReportExcel(ChargeInvoiceInhouse inhouse){
        List<String> departIds = chargeInvoiceRecordsMapper.getDepartIds(inhouse.getId());//获取机构Id
        List<ChargeInvoiceInhouse> houseList = null;
        if(null != departIds && departIds.size()> 0){
            houseList =  ChargeInvoiceInhouseMapper.getIhouseByDepartIds(departIds);
        }
        return houseList;
    }
}
